package dry.example.study;

/**
 * @author zc
 */
public class String2binary {

    /**
     * 字符串转二进制
     * 把每个字符的ascii码转为二进制
     *
     * @param data 待处理字符串
     * @return String
     */
    public static String string2binary(String data) {
        char[] array = data.toCharArray();
        StringBuilder result = new StringBuilder();
        for (char c : array) {
            result.append(Integer.toBinaryString(c));
        }
        return result.toString();
    }

    public static void main(String[] args) {
        System.out.println(string2binary("id"));
    }

}
